package com.luotf.controller.admin;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.luotf.model.Bloger;
import com.luotf.model.Menu;
import com.luotf.service.menuService;

@Controller
@RequestMapping(value="/admin")
public class MenuControllerAdmin {
	
	
	@Autowired
	private menuService menuservice;
	
	/**
	 * 
	 *@作者:
	 *@简介: 根据权限获得菜单
	 * @param session
	 * @return
	 */
	@RequestMapping(value="/getmenus",method=RequestMethod.POST)
    @ResponseBody
    public List<Menu> getmenus(HttpSession session){
		
   	 	//从session 中获得当前登录的人
		Bloger bloger = (Bloger) session.getAttribute("bloger");
		//判断是不是超级管理员管理员（超级管理员菜单是不受限制的）
		if(bloger.getHasPermission().equals(1)) {
			
			return menuservice.queryAll();
		}
   	 
   	 	return menuservice.queryByrole(bloger);
    }
}
